package com.yigo.cuc.app.assembler;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yigo.cuc.api.customer.command.CustomerRegisterCmd;
import com.yigo.cuc.api.customer.resp.CustomerListResp;
import com.yigo.cuc.api.customer.resp.CustomerRegisterResp;
import com.yigo.cuc.domain.customer.aggregateroot.Customer;
import com.yigo.cuc.infra.repo.dataobject.CustomerPO;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.*;

/**
 * @author chenzl
 */
@Mapper
public interface CustomerDTO2DmoAssembler {
    CustomerDTO2DmoAssembler INSTANCE = Mappers.getMapper(CustomerDTO2DmoAssembler.class);

    @Mapping(target = "userName", source = "source.userName.userName")
    @Mapping(target = "password", source = "source.password.password")
    @Mapping(target = "phone", source = "source.phone.phone")
    @Mapping(target = "email", source = "source.email.email")
    CustomerRegisterCmd toRegisterCmd(Customer source);

    @InheritInverseConfiguration(name = "toRegisterCmd")
    Customer toDmo(CustomerRegisterCmd source);

    CustomerRegisterResp toRegisterResp(Customer customer);

    List<CustomerListResp> toListResp(List<CustomerPO> source);
}
